<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" session="false"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>login.jsp</title>
<script type="text/javascript">
   window.onload=function(){
		//处理记住用户名  读取浏览器中的cookie,并把cookie数据放在文本框中
		var uname="${cookie.remname.value}";
		//alert(uname);
		document.forms[0].userName.value=decodeURI(uname);
		
		//处理10天自动登录
		var autologin_value="${cookie.autologin.value}";
		if(autologin_value!=""){
			var infos=autologin_value.split("#");
			//alert(infos[0]+"   "+infos[1]);
			document.forms[0].userName.value=decodeURI(infos[0]);
			//解密后的值=window.atob(base64加密的密文)
			document.forms[0].userPassword.value=window.atob(infos[1]);
			//用js代码的方式提交登录表单,然后会携带所有的cookie,并发送给服务端
			document.forms[0].submit();
		}
   }
</script>
</head>
<body>
	<div style="text-align:center;">
	<div>在线人数${applicationScope.onLine}</div>
	<div>在线人数${applicationScope.onLineUser}</div>
		<div style="font-size:30px;font-weight:bold;">用户登录</div>	
		<form action="login.do" method="post">
		<table border="1" align="center">
			<tr>
				<td>用户名:</td>
				<td><input type="text" name="userName" value="${sessionScope.user_name}"/></td>
			</tr>
			<tr>
				<td>密码:</td>
				<td><input type="password" name="userPassword" value="${sessionScope.user_password}"/></td>
			</tr>
			<tr>
				<td>验证码:</td>
				<td>
				   <input type="text" name="validateCode" size="5"/>
				   <img style="cursor:pointer;" title="点击更换"  src="CodeServlet.do" onclick="this.src='CodeServlet.do?'+Math.random();"/>
				   <span style="color:red;">${requestScope.messagecode}</span>
				</td>
			</tr>
			<tr>
				<td>选项:</td>
				<td>
				   <input type="checkbox" name="remembername" value="true" />记住用户名
				   <input type="checkbox" name="autologin" value="true" />10天自动登录
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="submit" value="登录" />
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="reset" value="重置" />
				</td>
			</tr>
		</table>
		</form>
	</div>
</body>
</html>